package Kuaishou;

import java.util.List;
import java.util.Objects;

import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonIgnore;

import com.google.common.collect.Lists;

import lombok.Data;

/**
 * @author leiwenkang <leiwenkang@kuaishou.com>
 * Created on 2020-12-27
 */
public class Test24equals和hashCode {
    public static void main(String[] args) {
        OrientationDetail orientationDetail1 = new OrientationDetail(true, Lists.newArrayList(1L, 2L)
                , Lists.newArrayList(3L, 4L, 5L), Lists.newArrayList(6L));

        OrientationDetail orientationDetail2 = new OrientationDetail(true, Lists.newArrayList(1L, 2L)
                , Lists.newArrayList(3L, 4L, 5L), Lists.newArrayList(6L));

        OrientationDetail orientationDetail3 = new OrientationDetail(false, Lists.newArrayList(1L, 2L)
                , Lists.newArrayList(3L, 4L, 5L), Lists.newArrayList(6L));

        System.out.println(orientationDetail1.equals(orientationDetail2));
        System.out.println(orientationDetail1.equals(orientationDetail3));
        System.out.println(orientationDetail1.hashCode());
        System.out.println(orientationDetail2.hashCode());
        System.out.println(orientationDetail3.hashCode());

    }
}

@Data
class OrientationDetail {
    private boolean isQuery;
    private List<Long> orientationList;
    private List<Long> excludePopulationList;
    private List<Long> paidAudienceList;

    public OrientationDetail(boolean isQuery, List<Long> orientationList, List<Long> excludePopulationList,
            List<Long> paidAudienceList) {
        this.isQuery = isQuery;
        this.orientationList = orientationList;
        this.excludePopulationList = excludePopulationList;
        this.paidAudienceList = paidAudienceList;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        OrientationDetail that = (OrientationDetail) o;
        return Objects.equals(orientationList, that.orientationList) &&
                Objects.equals(excludePopulationList, that.excludePopulationList) &&
                Objects.equals(paidAudienceList, that.paidAudienceList);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orientationList, excludePopulationList, paidAudienceList);
    }
}
